import shutil
import os

os.chdir("/Users/ddy/py/test")
if os.path.exists("./copy_from_test.txt"):
    os.unlink("./copy_from_test.txt")
copy_from_test = shutil.copy("test.txt", "copy_from_test.txt")  # cp
print(copy_from_test)

if not os.path.exists("../destination_dir"):
    if os.path.exists("./destination_dir"):
        shutil.rmtree("./destination_dir")
    shutil.copytree("test_dir", "destination_dir")  # cp -r
    shutil.move("destination_dir", "../")  # mv


os.unlink("copy_from_test.txt")
for file in os.listdir("../destination_dir"):
    os.unlink("../destination_dir/" + file)
os.rmdir("../destination_dir")


for folderName, subfolders, filenames in os.walk('./'):  # 3 个返回值
    print('The current folder is ' + folderName)
    for subfolder in subfolders:
        print('SUBFOLDER OF ' + folderName + ': ' + subfolder)
    for filename in filenames:
        print('FILE INSIDE ' + folderName + ': '+ filename)
    print('')
